﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FCTC_Web.Utilities;

namespace FCTC_Web.Controllers
{
    public class SearchController : Controller
    {
        //
        // GET: /Search/

        public ActionResult Index()
        {
        
            return View();
        }

        public RedirectToRouteResult SearchVehicle(string CarBrand, string BrandType, string VehicleStyle, string gears, string miles, string age, string prize)
        {
            return RedirectToAction("SearchVehicle", "VehicleBusiness", new { CarBrand, BrandType, VehicleStyle, gears, miles, age, prize });
        }

        public void SetBrandTypeStyle(string brand, string style, string selection, string gears,string miles,string age,string prize)
        {
            var ns = VehicleXmlHelper.Brands;
            ViewBag.CarBrand = new SelectList(ns);
            if (!string.IsNullOrWhiteSpace(brand))
                ViewBag.BrandType = new SelectList(VehicleXmlHelper.GetSelectiosn(brand));
            else
                ViewBag.BrandType = new SelectList(new List<string>());

            if (!string.IsNullOrWhiteSpace(selection))
                ViewBag.VehicleStyle = new SelectList(VehicleXmlHelper.GetvehicleType(brand, selection));
            else
                ViewBag.VehicleStyle = new SelectList(new List<string>());
        }


        public PartialViewResult BrandUpdateType(string brand)
        {
            if (!string.IsNullOrWhiteSpace(brand))
                ViewBag.BrandType = new SelectList(VehicleXmlHelper.GetSelectiosn(brand));
            else
                ViewBag.BrandType = new SelectList(new List<string>());
            return PartialView(@"~\views\shared\searchengine\VehicleType.cshtml");
        }

        public PartialViewResult BrandUpdateStyle(string style)
        {
            ViewBag.VehicleStyle = new SelectList(new List<string>());
            return PartialView(@"~\views\shared\searchengine\VehicleStyle.cshtml");
        }

        public PartialViewResult TypeUpdateStyle(string brand, string type)
        {
            if (!string.IsNullOrWhiteSpace(brand) && !string.IsNullOrWhiteSpace(type))
                ViewBag.VehicleStyle = new SelectList(VehicleXmlHelper.GetvehicleType(brand, type));
            else
                ViewBag.VehicleStyle = new SelectList(new List<string>());

            return PartialView(@"~\views\shared\searchengine\VehicleStyle.cshtml");

        }

    }
}
